<?php		




class IndexFace extends FaceBase{

	private $nohf = array('index');
	/**
	 * 构造函数，初始化插件
	 */
	public function __construct() {
		parent::__construct();

		if(!in_array(N_ACTION,$this->nohf)){
			n_mod('skin')->header();
		}
	}
	public function index()
	{
		n_mod('skin')->header();
		$this->_html('index');
	}
	public function indexOld()
	{
		$param = $this->param('cid:char:ignore');
		if (isset($param['cid']))
			$cid = $param['cid'];
		else
			$cid = 1;

		$weixin = n_api('weixin');
		$mprank = n_api('mprank');
		$mysql = n_api('mysql')->cname('weixin');

		$data = [];
		$data['cid'] = $cid;
		$categories = $weixin->getCategories();
		$weixinLists = [];
		$maxday = $mprank->getMaxRankDay();

		foreach ($categories as $category) {
			$data['cateTree'][$category['first_category']][] = ['sname' => $category['second_category'], 'sid'=>$category['id']];
			$categoryName = $category['second_category'];
			if ($category['id'] == $cid)
				$weixinLists[$categoryName] = $mprank->getMprankByCategoryId($category['id'], $maxday, 'day', 0, 12);
		}
		
		$data['slides'] = n_api('page')->getAllSlides();
		$data['categories'] = $categories;
		// $data['wxidSogou'] = $wxidArr;
		$data['weixinLists'] = $weixinLists;
		$data['hot_articles'] = n_api('article')->getHotArticleAll(5);
		$this->_html('index', $data);
	}

	public function cooperate()
	{
		$this->_html('cooperate');
	}
	public function myad()
	{
		$this->_html('myad');
	}
	public function classroom()
	{
		$this->_html('classroom');
	}
	public function help()
	{
		$this->_html('help');
	}
	public function __destruct(){
		if(!in_array(N_ACTION,$this->nohf)){
			n_mod('skin')->footer();
		}
	}
}

